#include <iostream>
#include<algorithm>
#include <string.h>
#include<fstream>
#include<time.h>
#include<stack>
#include<vector>
#include<sstream>
using namespace std;
int main()
{
	int n;
	while (cin >> n)
	{
		int *x = new int[n];
		int *y = new int[n];
		int *temp = new int[n];
		for (int i = 0; i < n; i++)
		{
			cin >> x[i] >> y[i];
		}
		sort(x, x + n);
		sort(y, y + n);
		for (int i = 0; i < n; i++)
		{
			temp[i] = x[i] - i;
		}
		sort(temp, temp + n);
		int ans = 0;
		for (int i = 0; i < n; i++)
		{
			ans += abs(y[i] - y[n / 2]);
			ans += abs(x[i] - (temp[n / 2]+i));
		}
		cout << ans << endl;
		delete x;
		delete y;
		delete temp;
	}
	return 0;
}